from cectest.common.com import run_algorithm_experiments, plot_algorithms_by_function
from cectest.common.alg import *

dim = 50
pop_size = 100
Tmax = 1000
ub = 100
lb = -100
population = initialization(pop_size, dim, ub, lb) # 种群初始化，共用同一种群
# im_ga_conv_curves = run_algorithm_experiments(hybrid_GA_CPO, "save/IM_GA_results_cec2017", dim, pop_size, Tmax, ub, lb, population)
# print("------------IM_GA在cec测试成功------------")
# gwo_conv_curves = run_algorithm_experiments(GWO, "save/GWO_results_cec2017", dim, pop_size, Tmax, ub, lb, population)
# print("------------GWO在cec测试成功------------")
# pso_conv_curves = run_algorithm_experiments(PSO, "save/PSO_results_cec2017", dim, pop_size, Tmax, ub, lb, population)
# print("------------PSO在cec测试成功------------")
woa_conv_curves = run_algorithm_experiments(WOA, "save/WOA_results_cec2017", dim, pop_size, Tmax, ub, lb, population)
print("------------WOA在cec测试成功------------")
com_ga_conv_curves = run_algorithm_experiments(COMGA, "save/COM_GA_results_cec2017", dim, pop_size, Tmax, ub, lb, population)
print("------------COM_GA在cec测试成功------------")
im_ga_conv_curves = run_algorithm_experiments(IMGAOne, "save/IM_GA_results_cec2017", dim, pop_size, Tmax, ub, lb, population)
print("------------IM_GA在cec测试成功------------")
cpo_conv_curves = run_algorithm_experiments(CPO, "save/CPO_results_cec2017", dim, pop_size, Tmax, ub, lb, population)
print("------------CPO在cec测试成功------------")
print("开始绘制所有算法的收敛曲线到同一张图中...")
# algorithms = {
#     "GA":com_ga_conv_curves,
#     "Improved_GA":im_ga_conv_curves,
#     "CPO": cpo_conv_curves,
#     "GWO": gwo_conv_curves,
#     "WOA": woa_conv_curves,
#     "PSO": pso_conv_curves
# }
algorithms = {
    "GA":com_ga_conv_curves,
    "Improved_GA": im_ga_conv_curves,
    "WOA": woa_conv_curves,
    "CPO": cpo_conv_curves,
}
plot_algorithms_by_function(algorithms, "save/ALG_results_cec2017")